package logic

import (
	"context"
	"shell/shellrpc/shellrpc"

	"shell/api/internal/svc"
	"shell/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type HomeListLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewHomeListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *HomeListLogic {
	return &HomeListLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *HomeListLogic) HomeList(req *types.HomeListRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line

	list, err := l.svcCtx.ShellRpc.HomeList(l.ctx, &shellrpc.HomeListRequest{})
	if err != nil {
		return &types.Response{
			Message: "列表失败",
			Code:    500,
			Data:    nil,
		}, nil
	}

	return &types.Response{
		Message: "列表成功",
		Code:    200,
		Data:    list,
	}, nil
}
